package com.yao.ecommerce.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NacosClientService {

    private final DiscoveryClient discoveryClient;

    public NacosClientService(DiscoveryClient discoveryClient) {
        this.discoveryClient = discoveryClient;
    }
    public List<ServiceInstance> getNacosClientInfo(String serviceId){
        try{

            Thread.sleep(2000);

        }catch (Exception ex){
            //

        }

        log.info(" reques nacos client to get nacos sercice info [{}]" ,serviceId);
        return discoveryClient.getInstances(serviceId);

    }
}
